package queue

import (
	"github.com/gogf/gf/v2/container/gvar"
	"github.com/gogf/gf/v2/os/gtime"
)

// QueuePriority

type QueuePriority string

const (
	QueuePriorityHigh    QueuePriority = "h"
	QueuePriorityLow     QueuePriority = "l"
	QueuePriorityDefault QueuePriority = "d"
)

// QueueJob

func newQueueJob(job interface{}, priority QueuePriority) *QueueJob {
	return &QueueJob{
		Job:          gvar.New(job),
		Priority:     priority,
		DispatchedAt: gtime.Now().TimestampMilli(),
	}
}

type QueueJob struct {
	ID           string        `json:"i,omitempty"`
	ChannelName  string        `json:"c,omitempty"`
	Job          *gvar.Var     `json:"j"`
	Priority     QueuePriority `json:"p"`
	DispatchedAt int64         `json:"d"`
	HandledAt    int64         `json:"h,omitempty"`
}
